<template>
	<view class="card-list">
		<view @click="handleCard(item)" class="card-item" v-for="(item, index) of props.cardList" :key="index">
			<view class="content">
				<img class="item-img" v-if="item.mediaList != null && item.mediaList.length > 0" :src="item.mediaList[0].url" alt="" />
				<p class="title">{{item.content}}</p>
			</view>
			<view class="bottom">
				<p>{{item.userName + '-' + item.livingCity}}</p>
				<p>{{ item.createTime.slice(0,10) }}</p>
			</view>
		</view>
	</view>
</template>

<script setup>
	const props = defineProps(['cardList'])
	const emit = defineEmits(['clickCard'])
	
	const handleCard = (item) => {
		emit('clickCard', item)
	}
</script>

<style lang="scss">
	.card-list{
		padding: 20rpx 30rpx;
		width: 100%;
		display: flex;
		flex-wrap: wrap;
		justify-content: space-between;
		.card-item {
			display: flex;
			flex-direction: column;
			justify-content: space-between;
			width: calc(50% - 40rpx);
			height: 365rpx;
			margin: 20rpx 20rpx;
			border-radius: 10rpx;
			background-color: #fff;
			box-shadow:
			  0px 0px 7px rgba(0, 0, 0, 0.23)
			;
			padding: 15rpx 25rpx;
			.content{
				flex: 1;
				.item-img{
					width: 250rpx;
					max-height: 250rpx;
					border-radius: 10rpx;
					margin: 0 auto;
				}
				.title{
					font-size: 20rpx;
					font-weight: 800;
					word-break: break-all;
					overflow: hidden;
					display: -webkit-box;
					-webkit-line-clamp: 2;
					-webkit-box-orient: vertical;
				}
			}
			.bottom {
				display: flex;
				align-items: center;
				justify-content: space-between;
				padding: 10rpx 7rpx 0 7rpx;
				font-size: 15rpx;
				color: #676767;
			}
		}
	}
</style>